#include "LockGuard.hpp"
#include "Task.hpp"
#include "Thread.hpp"
#include "ThreadPool.hpp"
#include <unistd.h>
#include <ctime>
#include <sys/types.h>
#include <unistd.h>
int main()
{
    int x;
    int y;
    char op;
    srand((unsigned int)time(nullptr) ^ getpid());
    //ThreadPool<Task>* tp = new ThreadPool<Task>();
    //tp->run();
    ThreadPool<Task>::GetInstance()->run();
    while(1)
    {
        // std::cout << "请输入一个数据1# ";
        // std::cin >> x;
        // std::cout << "请输入数据2# ";
        // std::cin >> y;
        // std::cout << "请输入操作符# ";
        // std::cin >> op;
        

        x = rand() % 20;
        y = rand() % 10;
        op = operations[rand() % operations.size()];
        Task t(x, y, op, MyMath);
        // std::cout << "你刚刚录入了一个任务: " << t.ToString() << "， 确认提交吗？[y/n]# ";
        std::cout << "你刚刚录入了一个任务: " << t.ToString() << std::endl;

        // char confirm;
        char confirm = 'y';

        // std::cin >> confirm;
        if('y' == confirm)
        {
            //tp->push(t);
            ThreadPool<Task>::GetInstance()->push(t);
        }
        usleep(100000);
    }
    return 0;
}